﻿using CatSimulator.Models;
using Loli.Library.WinForm;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CatSimulator
{
    public partial class StepBasic : FormBase
    {
        private GameConfig _Config = DataFactory.GetGameConfig();
        public StepBasic()
        {
            InitializeComponent();
#if DEBUG
            _Config.GamePath = @"D:\Maple\GameLauncher.exe";
#endif
        }

        private void butBrowse_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.FileName = "GameLauncher.exe";
            dialog.Filter = "冒险岛执行程序|GameLauncher.exe";
            dialog.Title = "请选择冒险岛可执行程序";


            DialogResult result = dialog.ShowDialog(this);

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                tbGamePath.Text = dialog.FileName.Trim();
                _Config.GamePath = tbGamePath.Text;
            }
        }

        private void butRun_Click(object sender, EventArgs e)
        {

            if (string.IsNullOrEmpty(_Config.GamePath))
            {
                LoliMessageBox.Show(this, "请选择游戏路径！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

                butBrowse.Focus();
            }
            else
            {
                Process.Start(_Config.GamePath);
            }
        }

        protected override bool UpdateInfo()
        {
            if (string.IsNullOrEmpty(_Config.GamePath))
            {
                LoliMessageBox.Show(this, "请选择游戏路径！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                butBrowse.Focus();
                return false;
            }

            return true;
        }
    }
}
